//package com.eastfair.transaction.mq.listener;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.eastfair.mq.model.MySimpleMessage;
//import com.eastfair.mq.util.MessageExtUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.spring.annotation.ConsumeMode;
//import org.apache.rocketmq.spring.annotation.MessageModel;
//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
//import org.apache.rocketmq.spring.core.RocketMQListener;
//import org.apache.rocketmq.spring.core.RocketMQTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import java.util.Map;
//
///**
// * @Description: 事务消费
// * @author: ligang
// * @date: 2022年05月01日 16:43
// */
//@Slf4j
//@Component
//@RocketMQMessageListener(topic = "${rocketmq.consumer.transactionTopic}", consumerGroup = "${rocketmq.consumer.transactionTopicConsumer}",
//        selectorExpression = "auth_loadUserPermiss || auth_loadUserPermissOfOrg ||auth_loadUserPermissOfRole ",
//        messageModel = MessageModel.CLUSTERING, consumeMode = ConsumeMode.ORDERLY)
//public class TransactionListner implements RocketMQListener<MySimpleMessage> {
//    @Autowired
//    private MessageExtUtil messageExtUtil;
//
//    @Autowired
//    private RocketMQTemplate rocketMQTemplate;
//
//    @Value("${rocketmq.consumer.transactionTopic}")
//    private String transactionTopic;
//
////    @Autowired
////    private StoreService storeService;
//
//    @Override
//    public void onMessage(MySimpleMessage mySimpleMessage) {
//        log.info("事务消费接收：" + JSON.toJSONString(mySimpleMessage, true));
//        //消息是否已经消费
//        if (messageExtUtil.isUseMessage(mySimpleMessage)) {
//            return;
//        }
//
//        Map<String, Object> headers = mySimpleMessage.getHeaders();
//        String tag = headers.get("tag").toString();
////        if (PointKeyDefinition.TRANSACTION_ORDER.equals(tag)) {
//////            OrderTransaction orderTransaction = JSONObject.parseObject(mySimpleMessage.getPayload().toString(),OrderTransaction.class);
////            String body = JSONObject.toJSONString(mySimpleMessage.getPayload());
////            log.info(body);
////            OrderTransaction orderTransaction = JSONObject.parseObject(body, OrderTransaction.class);
////            //调用执行发送仓库队列
////            StoreTransaction storeTransaction = new StoreTransaction();
////            storeTransaction.setStore(1111);
////            storeTransaction.setOrderNumber("23333");
////            storeService.sendQueueMessage(storeTransaction);
////        }else if (PointKeyDefinition.TRANSACTION_STORE.equals(tag)) {
////            String body = JSONObject.toJSONString(mySimpleMessage.getPayload());
////            StoreTransaction storeTransaction = JSONObject.parseObject(body, StoreTransaction.class);
////            //调用积分功能
////        }
//        //清空缓存key
//        messageExtUtil.removeKey(mySimpleMessage);
//
//    }
//
//}
